// IM通讯
import { ajaxService } from '@/utils/request';
import { Contacts, WsMsg, MsgParams, MsgLogParams } from './type';

const env = import.meta.env;
const baseURL = env.VITE_DEV_BASE_URL;
// const baseURL = env.VITE_APP_BASE_URL;

/**
 * 获取IM通讯记录列表
 * @param params
 * @returns
 */
export async function getImMsgList(params: MsgParams) {
  return ajaxService<{ content?: Contacts[]; pageable?: any }>({
    url: '/hr/workbench/communication/record/list',
    method: 'get',
    baseURL,
    params
  });
}

/**
 * 获取聊天记录
 * @param params
 * @returns
 */
export async function getImMsgLogList(params: MsgLogParams) {
  return ajaxService<{ content?: Contacts[]; pageable?: any }>({
    url: '/hr/workbench/communication/record/log',
    method: 'get',
    baseURL,
    params
  });
}

/**
 * 获取聊天记录
 * @param params
 * @returns
 */
export async function delImMsgLogList(data: { ids: number[] }) {
  return ajaxService<{ content?: Contacts[]; pageable?: any }>(
    {
      url: '/hr/workbench/communication/record/delete',
      method: 'DELETE',
      baseURL,
      data
    },
    {
      message: '删除成功',
      mode: 'success'
    }
  );
}
